﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UserGUI : MonoBehaviour
{
    IUserAction userAction;
    string result;
    int points;
    int round;
    int mode;
    int flyMode;

    public void SetResult(string result){
        this.result = result;
    }

    public void SetPoints(int points){
        this.points = points;
    }

    public void SetRound(int round){
        this.round = round;
    }

    public void SetMode(int mode){
        this.mode = mode;
    }

    public void SetFlyMode(int flyMode){
        this.flyMode = flyMode;
    }

    void Start()
    {
        result = "";
        points = 0;
        round = 1;
        mode = 1;
        flyMode = 0;
        userAction = SSDirector.GetInstance().CurrentScenceController as IUserAction;
    }
    
    // 打印和用户交互提示界面
    void OnGUI()
    {
        GUIStyle titleStyle = new GUIStyle();
        titleStyle.normal.textColor = Color.blue;
        titleStyle.fontSize = 50;

        GUIStyle style = new GUIStyle();
        style.normal.textColor = Color.black;
        style.fontSize = 30;

        GUIStyle resultStyle = new GUIStyle();
        resultStyle.normal.textColor = Color.red;
        resultStyle.fontSize = 50;

        GUIStyle modeStyle = new GUIStyle();
        modeStyle.normal.textColor = Color.blue;
        modeStyle.fontSize = 40;

        GUI.Label(new Rect(Screen.width / 2 - 100, 30, 200, 50), "Hit UFO", titleStyle);
        GUI.Label(new Rect(20, 10, 100, 50), "回合: " + round, style);
        GUI.Label(new Rect(20, 60, 100, 50), "得分: " + points, style);
        GUI.Label(new Rect(20, 180, 100, 50), "飞碟运动模式", style);
        GUI.Label(new Rect(20, 360, 100, 50), "游戏难度模式", style);
        GUI.Label(new Rect(Screen.width / 2 - 125, Screen.height / 2 - 100, 200, 200), result, resultStyle);


        if (GUI.Button(new Rect(240, 15, 100, 75), "重新开始"))
        {
            userAction.Restart();
        }
        // 简单模式
        if (GUI.Button(new Rect(20, 400, 100, 50), "简单"))
        {
            userAction.SetMode(0);
        }
        // 通常模式
        if (GUI.Button(new Rect(20, 470, 100, 50), "一般"))
        {
            userAction.SetMode(1);
        }
        // 困难模式
        if (GUI.Button(new Rect(20, 540, 100, 50), "困难"))
        {
            userAction.SetMode(2);
        }
        // 无限模式
        if (GUI.Button(new Rect(20, 610, 100, 50), "无尽"))
        {
            userAction.SetMode(3);
        }
        // 运动学模式
        if (GUI.Button(new Rect(20, 220, 100, 50), "运动学模式"))
        {
            userAction.SetFlyMode(0);
        }
        // 动力学模式
        if (GUI.Button(new Rect(20, 290, 100, 50), "动力学模式"))
        {
            userAction.SetFlyMode(1);
        }

        // 捕捉鼠标点击
        if (Input.GetButtonDown("Fire1"))
        {
            userAction.Hit(Input.mousePosition);
        }
    }
}
